package main

import (
	"fmt"
	"unsafe"
)

// #cgo CPPFLAGS: -I../../../cc/src/include
// #cgo LDFLAGS: -L../../../build/lib -larrow_c
//
// #include <allocate_bytes.h>
import "C"

func main() {
	// 1. 定义声明GO byte[] 切片
	goBytes := make([]byte, 16)
	for i := 0; i < cap(goBytes); i++ {
		goBytes[i] = byte(i)
	}

	// 2. 输出该字节数组
	for _, value := range goBytes {
		fmt.Printf("%b  ", value)
	}
	fmt.Println()

	cBytes := C.AllocateBytes()

	_ = cBytes
	fmt.Printf("address = %v\n", cBytes)
	unsafeBytes := (*[16]byte)(unsafe.Pointer(cBytes))[:]
	for i := 0; i < 16; i++ {
		fmt.Printf("%b  ", unsafeBytes[i])
	}
	fmt.Println()

}
